<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" isELIgnored ="false"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<%
	String path = request.getContextPath();
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
	<head>
		<title>北京市电子行政监察平台-编辑数据规则权限资源集</title>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<link href="<%=path%>/css/base.css" rel="stylesheet" type="text/css" />
		<link href="<%=path%>/css/style.css" rel="stylesheet" type="text/css" />
		<link href="<%=path%>/css/frame.css" rel="stylesheet" type="text/css" />
		<script type="text/javascript">
			var path = "<%=path%>";
		</script>
		<script type="text/javascript" src="<%=path%>/javascript/core/jquery-1.6.1.min.js"></script>
		<script type="text/javascript" src="<%=path%>/javascript/core/jquery.metadata.js"></script>
		<script type="text/javascript" src="<%=path%>/javascript/core/jquery-jtemplates.pack.js"></script>
		<script type="text/javascript" src="<%=path%>/javascript/core/jquery.validate.fixed.pack.js"></script>
		<script type="text/javascript" src="<%=path%>/javascript/system/util.js"></script>
		<script type="text/javascript" src="<%=path%>/javascript/system/oacore.js"></script>
		<script type="text/javascript" src="<%=path%>/javascript/system/init.js"></script>
		<script type="text/javascript">
		//删除规则
		  function removeRule(ruleId,version,ruleName,ruleOrder,ruleState,resourceId){
			  oacore.Widget.Dialog.confirm("删除确认", "您确认删除此条记录?", function () {
					 var state='';
					 if(ruleState=='D'){
						 state='禁用';
					 }else if(ruleState=='E'){
		                 state='启用';
					 }
		             document.getElementById("ruleName").value=ruleName;
		             document.getElementById("ruleOrder").value=ruleOrder;
		             document.getElementById("ruleState").value=state;
		             document.getElementById("ruleId").value=ruleId;
		             document.getElementById("version").value=version;
		             document.getElementById("resourceId").value=resourceId;
		             var oForm=document.forms[1];
		             //oForm.action="<%=path%>/web/removeRuleAction.action";
		             oForm.submit();
				  });
	      }

	      $(function () {
				//初始化表单值校验器
				var validator = $("#updateResource").validate();
		      });
		</script>
		<style type="text/css">
			div {
				position: static;
			}
		</style>
	</head>
	<body>
		<div id="mainPage" class="surround-layout">
			<jsp:include page="../frame/top.jsp" flush="true"></jsp:include>
			<div class="middle">
				<jsp:include page="../frame/middle_left.jsp" flush="true">
					<jsp:param value="1026-1033" name="view"/>
				</jsp:include>
				<!-- 右侧输出内容 -->
				<div class="right">
					<div class="right-all-content">
						<div>
							<div class="content-line-wrap">
								<div class="content-line-left content-line">
									<h1 class="content-title">
										<span>
											<a href="<%=path %>/web/initResourceByPageAction.action">数据权限规则管理</a>
										</span>
										<span>
											&gt;&gt;
										</span>
										<span>
											<a href="<%=path %>/web/findResourceByIdAction.action?rid=${rid}">编辑资源集</a>
										</span>
									</h1>
								</div>
							</div>
							<div class="inner-dialog">
								<h1 class="inner-dialog-title">编辑资源集</h1>
								<div class="inner-dialog-content">
									<!-- 填入action地址 -->
									<form method="post" action="<%=path %>/web/updateResourceAction.action"  name="updateResource" id="updateResource" class="normal-form">
										<input type="hidden" name="resourcePermissionDTO.resourceId" value="${resourcePermissionDTO.resourceId}">
										<table>
											<tr>
												<td>
													<span class="form-field bold-field">资 源 集 名:</span>
													<input type="text" name="resourcePermissionDTO.resourceName" value="${resourcePermissionDTO.resourceName}" readonly="readonly" class="shadow nf-double-cell"/>
												</td>
											</tr>
											<tr>
												<td>
													<span  class="form-field">描　　　　述:</span>
													<input type="text" name="resourcePermissionDTO.resourceDescription" class="shadow nf-double-cell {maxlength: 64, messages: {maxlength: '不能超过64个字符'}}" value="${resourcePermissionDTO.resourceDescription}"/>
												</td>
											</tr>
											<tr>
												<td>
													<span  class="form-field">规则匹配策略:</span>
													<s:select list="#{'0':'唯一','1':'交集','2':'并集'}" headerKey="" cssClass="{required: true, messages: {required: '必填项'}}" name="resourcePermissionDTO.resourceMatch" value="resourcePermissionDTO.resourceMatch" headerValue="请选择级别" theme="simple"></s:select>
												</td>
											</tr>
										</table>
										<table style="width: 100%;">
											<tbody>
												<tr style="height: auto;">
													<td style="padding-right: 0;">
														<span class="form-field">规　　　　则:</span>
														<table class="data-table" cellspacing="0" style="width: 100%;">
															<thead>
																<tr style="height: 30px;">
																	<th class="data-head">规则顺序</th>
																	<th class="data-head">规则名</th>
																	<th class="data-head">状态</th>
																	<th class="data-head">操作</th>
																</tr>
															</thead>
															<tbody>
															      <s:if test="resourcePermissionDTO.ruleDtos.size==0">
															      			<tr class="odd last" style="height: 30px;">
															      			<td colspan="4" class="data-table-no-data-td">没有数据</td>
															      			</tr>
															      </s:if>
															    <s:iterator value="resourcePermissionDTO.ruleDtos" id="rule" status="statu">
															       <s:if test="#statu.odd">
															       <s:if test="#statu.last">
															       	<tr class="odd last" style="height: 30px;">
																	<td><s:property value="#rule.ruleOrder"/></td>
																	<td><s:property value="#rule.ruleName"/></td>
																	<td>
																	<s:if test='#rule.ruleState=="D"'>禁用</s:if>
																	<s:elseif test='#rule.ruleState=="E"'>启用</s:elseif></td>
																	<td>
																		<a href="findRuleByIdAction.action?ruleId=${rule.ruleId}">编辑</a>
																		<a href="javascript: removeRule(${rule.ruleId},${rule.version},'${rule.ruleName}','${rule.ruleOrder}','${rule.ruleState}','${resourcePermissionDTO.resourceId}');">删除</a>
																	</td>
																    </tr>
															       </s:if>
															       <s:else>
															       	<tr class="odd" style="height: 30px;">
																	<td><s:property value="#rule.ruleOrder"/></td>
																	<td><s:property value="#rule.ruleName"/></td>
																	<td>
																	<s:if test='#rule.ruleState=="D"'>禁用</s:if>
																	<s:elseif test='#rule.ruleState=="E"'>启用</s:elseif></td>
																	<td>
																		<a href="findRuleByIdAction.action?ruleId=${rule.ruleId}">编辑</a>
																		<a href="javascript: removeRule(${rule.ruleId},${rule.version},'${rule.ruleName}','${rule.ruleOrder}','${rule.ruleState}','${resourcePermissionDTO.resourceId}');">删除</a>
																	</td>
																    </tr>
															       </s:else>
															       </s:if>
															       <s:elseif test="#statu.even">
															       
															        <s:if test="#statu.last">
															       	<tr class="even last" style="height: 30px;">
																	<td><s:property value="#rule.ruleOrder"/></td>
																	<td><s:property value="#rule.ruleName"/></td>
																	<td>
																	<s:if test='#rule.ruleState=="D"'>禁用</s:if>
																	<s:elseif test='#rule.ruleState=="E"'>启用</s:elseif></td>
																	<td>
																		<a href="findRuleByIdAction.action?ruleId=${rule.ruleId}">编辑</a>
																		<a href="javascript: removeRule(${rule.ruleId},${rule.version},'${rule.ruleName}','${rule.ruleOrder}','${rule.ruleState}','${resourcePermissionDTO.resourceId}');">删除</a>
																	</td>
																    </tr>
															       </s:if>
															       <s:else>
															         	<tr class="even" style="height: 30px;">
																	<td><s:property value="#rule.ruleOrder"/></td>
																	<td><s:property value="#rule.ruleName"/></td>
																	<td>
																	<s:if test='#rule.ruleState=="D"'>禁用</s:if>
																	<s:elseif test='#rule.ruleState=="E"'>启用</s:elseif></td>
																	<td>
																		<a href="findRuleByIdAction.action?ruleId=${rule.ruleId}">编辑</a>
																		<a href="javascript: removeRule(${rule.ruleId},${rule.version},'${rule.ruleName}','${rule.ruleOrder}','${rule.ruleState}','${resourcePermissionDTO.resourceId}');">删除</a>
																	</td>
																    </tr>
															       </s:else>													     
															       </s:elseif>
															    </s:iterator>
															</tbody>
														</table>
													</td>
												</tr>
											</tbody>
										</table>
										<button onclick="javascript: oacore.Util.goUrl('/web/initAddRuleAction?resourceId=${resourcePermissionDTO.resourceId}');return false;" class="special fun-create" id="createEvent" style="float: right;">新增规则</button>
										<table>
											<tr>
												<td>
													<input type="submit" value="保存" class="special originate"></input>
												</td>
											</tr>
										</table>
									</form>
									<form action="<%=path%>/web/removeRuleAction.action">
										<input type="hidden" id="ruleName" name="ruleDTO.ruleName">
										<input type="hidden" id="ruleOrder" name="ruleDTO.ruleOrder">
										<input type="hidden" id="ruleState" name="ruleDTO.ruleState">
										<input type="hidden" id="version" name="ruleDTO.version">
										<input type="hidden" id="ruleId" name="ruleDTO.ruleId">
										<input type="hidden" id="resourceId" name="ruleDTO.resourceId">
									</form>
								</div>
							</div>
						</div>
					</div>
				</div>
				<!--  -->
			</div>
		</div>
	</body>
</html>